import { BaseComponent } from '../base/BaseComponent';

const { ccclass, property, executeInEditMode } = cc._decorator;

@ccclass
@executeInEditMode()
export class MaskProgressBar extends cc.ProgressBar {

    @property(cc.Node)
    mask: cc.Node = null!;

    @property(cc.Node)
    bar: cc.Node = null!;

    _progress: number = 0

    @property({override: true})
    set progress(val: number) {
        this._progress = val<0?0:val>1?1:val

        this.refreshBar()
    }

    get progress() {
        return this._progress
    }

    private refreshBar() {
        this.mask.width=this.bar.width * this._progress;
    }

}

